<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>公益商城 - 暖言树洞</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="css/style.css">
</head>
<body class="bg-gray-50 font-sans text-gray-800">
    <!-- 导航栏 -->
    <nav class="bg-white shadow-md fixed w-full z-10 top-0">
        <div class="container mx-auto px-4 py-3 flex justify-between items-center">
            <div class="flex items-center space-x-2">
                <i class="fas fa-tree text-green-500 text-2xl"></i>
                <span class="text-xl font-bold text-green-600">暖言树洞</span>
            </div>
            <div class="hidden md:flex space-x-6">
                <a href="index.html" class="text-gray-700 hover:text-green-500 transition-colors">首页</a>
                <a href="diary.html" class="text-gray-700 hover:text-green-500 transition-colors">心情日记</a>
                <a href="drift.html" class="text-gray-700 hover:text-green-500 transition-colors">漂流瓶</a>
                <a href="mall.html" class="text-green-500 font-medium">公益商城</a>
            </div>
            <div class="flex items-center space-x-4">
                <a href="profile.html" class="text-gray-700 hover:text-green-500 transition-colors">
                    <i class="fas fa-user-circle text-xl"></i>
                </a>
                <button class="md:hidden text-gray-700">
                    <i class="fas fa-bars text-xl"></i>
                </button>
            </div>
        </div>
    </nav>

    <!-- 主要内容 -->
    <main class="container mx-auto px-4 pt-24 pb-24">
        <div class="max-w-3xl mx-auto">
            <h1 class="text-3xl font-bold text-gray-800 mb-2">公益商城</h1>
            <p class="text-gray-600 mb-8">用暖心货币兑换公益热力值，一起传递温暖</p>

            <!-- 余额信息 -->
            <div class="bg-white rounded-xl shadow-md p-6 mb-8 flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <p class="text-gray-600 mb-1">当前暖心货币</p>
                    <div class="flex items-center">
                        <i class="fas fa-coins text-yellow-500 mr-2 text-xl"></i>
                        <span class="text-2xl font-bold">36</span>
                    </div>
                </div>
                <div class="flex items-center space-x-6">
                    <div class="text-center">
                        <p class="text-gray-600 mb-1">已拥有热力值</p>
                        <div class="flex items-center justify-center">
                            <i class="fas fa-fire text-red-500 mr-2"></i>
                            <span class="font-bold">8</span>
                        </div>
                    </div>
                    <div class="h-10 w-px bg-gray-200"></div>
                    <div class="text-center">
                        <p class="text-gray-600 mb-1">公益等级</p>
                        <div class="flex items-center justify-center">
                            <i class="fas fa-medal text-yellow-500 mr-2"></i>
                            <span class="font-bold">Lv.2</span>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 公益项目列表 -->
            <h2 class="text-xl font-semibold mb-4">公益项目</h2>
            <div class="space-y-6 mb-12">
                <!-- 项目1 -->
                <div class="bg-white rounded-xl shadow-md overflow-hidden">
                    <div class="md:flex">
                        <img src="https://picsum.photos/id/1015/300/200" alt="植树造林项目" class="w-full md:w-1/3 h-48 object-cover">
                        <div class="p-6 md:w-2/3">
                            <div class="flex justify-between items-start mb-2">
                                <h3 class="text-lg font-semibold">绿色希望 - 植树造林计划</h3>
                                <span class="badge badge-primary">热门</span>
                            </div>
                            <p class="text-gray-600 mb-4">每10点热力值可兑换1棵树苗，我们将在荒漠化地区种植并养护。你的每一份爱心，都能为地球增添一抹绿色。</p>
                            <div class="flex flex-wrap justify-between items-center">
                                <div class="flex items-center mb-3 md:mb-0">
                                    <i class="fas fa-fire text-red-500 mr-1"></i>
                                    <span class="text-gray-700 mr-4">所需热力值: <span class="font-medium">10</span></span>
                                    <i class="fas fa-users text-blue-500 mr-1"></i>
                                    <span class="text-gray-700">参与人数: 1,284</span>
                                </div>
                                <button class="exchange-btn btn-primary px-4 py-2 text-sm" data-project="植树造林" data-cost="10">
                                    <i class="fas fa-exchange-alt mr-1"></i> 立即兑换
                                </button>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 项目2 -->
                <div class="bg-white rounded-xl shadow-md overflow-hidden">
                    <div class="md:flex">
                        <img src="https://picsum.photos/id/26/300/200" alt="儿童教育支持" class="w-full md:w-1/3 h-48 object-cover">
                        <div class="p-6 md:w-2/3">
                            <div class="flex justify-between items-start mb-2">
                                <h3 class="text-lg font-semibold">童心守护 - 教育支持计划</h3>
                                <span class="badge badge-secondary">新上线</span>
                            </div>
                            <p class="text-gray-600 mb-4">每20点热力值可资助一名贫困地区儿童获得一个月的学习用品。让知识改变命运，让每个孩子都有梦想的权利。</p>
                            <div class="flex flex-wrap justify-between items-center">
                                <div class="flex items-center mb-3 md:mb-0">
                                    <i class="fas fa-fire text-red-500 mr-1"></i>
                                    <span class="text-gray-700 mr-4">所需热力值: <span class="font-medium">20</span></span>
                                    <i class="fas fa-users text-blue-500 mr-1"></i>
                                    <span class="text-gray-700">参与人数: 865</span>
                                </div>
                                <button class="exchange-btn btn-primary px-4 py-2 text-sm" data-project="儿童教育" data-cost="20">
                                    <i class="fas fa-exchange-alt mr-1"></i> 立即兑换
                                </button>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 项目3 -->
                <div class="bg-white rounded-xl shadow-md overflow-hidden">
                    <div class="md:flex">
                        <img src="https://picsum.photos/id/292/300/200" alt="流浪动物救助" class="w-full md:w-1/3 h-48 object-cover">
                        <div class="p-6 md:w-2/3">
                            <div class="flex justify-between items-start mb-2">
                                <h3 class="text-lg font-semibold">爱心家园 - 流浪动物救助</h3>
                                <span class="badge badge-primary">热门</span>
                            </div>
                            <p class="text-gray-600 mb-4">每15点热力值可资助一只流浪动物一周的食物和医疗护理。用爱心为它们提供一个温暖的家，让生命不再流浪。</p>
                            <div class="flex flex-wrap justify-between items-center">
                                <div class="flex items-center mb-3 md:mb-0">
                                    <i class="fas fa-fire text-red-500 mr-1"></i>
                                    <span class="text-gray-700 mr-4">所需热力值: <span class="font-medium">15</span></span>
                                    <i class="fas fa-users text-blue-500 mr-1"></i>
                                    <span class="text-gray-700">参与人数: 932</span>
                                </div>
                                <button class="exchange-btn btn-primary px-4 py-2 text-sm" data-project="流浪动物救助" data-cost="15">
                                    <i class="fas fa-exchange-alt mr-1"></i> 立即兑换
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 兑换记录 -->
            <div class="bg-white rounded-xl shadow-md p-6">
                <h2 class="text-xl font-semibold mb-4">我的兑换记录</h2>
                <div class="space-y-4">
                    <!-- 记录项1 -->
                    <div class="flex justify-between items-center pb-4 border-b border-gray-100">
                        <div>
                            <h3 class="font-medium">绿色希望 - 植树造林计划</h3>
                            <p class="text-sm text-gray-500">2023-10-15</p>
                        </div>
                        <div class="text-right">
                            <p class="font-medium text-red-500">-10 热力值</p>
                            <p class="text-xs text-gray-500">订单号:公益20231015001</p>
                        </div>
                    </div>

                    <!-- 记录项2 -->
                    <div class="flex justify-between items-center pb-4 border-b border-gray-100">
                        <div>
                            <h3 class="font-medium">童心守护 - 教育支持计划</h3>
                            <p class="text-sm text-gray-500">2023-09-28</p>
                        </div>
                        <div class="text-right">
                            <p class="font-medium text-red-500">-20 热力值</p>
                            <p class="text-xs text-gray-500">订单号:公益20230928045</p>
                        </div>
                    </div>

                    <!-- 查看更多 -->
                    <div class="text-center mt-2">
                        <button class="text-green-500 hover:text-green-600 text-sm">
                            查看更多记录 <i class="fas fa-chevron-down ml-1"></i>
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </main>

    <!-- 底部导航栏 (移动端) -->
    <nav class="md:hidden fixed bottom-0 w-full bg-white shadow-lg border-t border-gray-200">
        <div class="flex justify-around py-3">
            <a href="index.html" class="flex flex-col items-center text-gray-500">
                <i class="fas fa-home text-xl"></i>
                <span class="text-xs mt-1">首页</span>
            </a>
            <a href="diary.html" class="flex flex-col items-center text-gray-500">
                <i class="fas fa-pen-to-square text-xl"></i>
                <span class="text-xs mt-1">日记</span>
            </a>
            <a href="drift.html" class="flex flex-col items-center text-gray-500">
                <i class="fas fa-message text-xl"></i>
                <span class="text-xs mt-1">漂流瓶</span>
            </a>
            <a href="profile.html" class="flex flex-col items-center text-gray-500">
                <i class="fas fa-user text-xl"></i>
                <span class="text-xs mt-1">我的</span>
            </a>
        </div>
    </nav>

    <script>
        // 兑换功能
        document.querySelectorAll('.exchange-btn').forEach(btn => {
            btn.addEventListener('click', function() {
                const project = this.getAttribute('data-project');
                const cost = this.getAttribute('data-cost');
                const currentHeat = 8; // 当前热力值

                if (parseInt(cost) > currentHeat) {
                    alert(`兑换失败！你的热力值不足，当前拥有 ${currentHeat} 点，兑换${project}需要 ${cost} 点。`);
                } else {
                    alert(`成功兑换${project}！消耗 ${cost} 点热力值，感谢你的爱心贡献！`);
                }
            });
        });
    </script>
</body>
</html>